<template>
	<view>
		<!-- <page-head :title="'提现'" :headtype="2"></page-head> -->
		<view class="goalacc marginAuto">
			<view class="goalacctitle">到账账户</view>
			<view class="goalmsg flex" >
				<!-- @click="$refs.sepaytypepop.open()" -->
				<view class="goalmsgl flex" v-if="acpaytype == 1">
					<uv-icon name='weixin-circle-fill' size="26" color="#0ABC64"></uv-icon>
					<view class="goalmsgltxt">微信</view>
				</view>
				<view class="goalmsgl flex" v-if="acpaytype == 2">
					<uv-icon name='zhifubao-circle-fill' size="26" color="#1296DB"></uv-icon>
					<view class="goalmsgltxt">支付宝</view>
				</view>
				<!-- <view class="goalmsgr">
					<uv-icon name="arrow-right" size="20" color="#999999"></uv-icon>
				</view> -->
			</view>
		</view>
		<view class="withmoney marginAuto">
			<view class="paymenttitle marginAuto">
				<view class="paymenttitle-title">提现金额</view>
			</view>
			<view class="rechmoney marginAuto">
				<view class="rechmoney-b">￥</view>
				<view class="rechmoney-input">
					<input type="text" v-model="withnum" placeholder="自定义提现金额" />
				</view>
			</view>
			<view class="alpayinput marginAuto">
				<input type="text" v-model="username" placeholder="请输入您的真是姓名">
			</view>
			<view class="allmoeny">
				<text>当前可提现金额{{ allmoney }}</text>
				<text class="mainColor" style="margin-left:30rpx;" @click="withnum = allmoney">全部提现</text>
			</view>
		</view>
		<view class="marginAuto" style="width:600rpx;margin-top:150rpx;">
			<uv-button text="确认" @click="enter()" :customStyle="{
				'background':'#0E71EB',
				'color':'#ffffff',
				'font-size':'30rpx',
				'width':'600rpx',
				'height':'100rpx',
				'border-radius':'20rpx'
			}"></uv-button>
		</view>
		<uv-popup ref="sepaytypepop" :bgColor="`transparent`" mode="bottom" round="30" @close="$refs.sepaytypepop.close()">
			<view class="paytypeblock">
				<view class="buypopuptop">
					<view class="selectclose" @click="$refs.sepaytypepop.close()">
						<uv-icon size="26" color="#333333" name="close" />
					</view>
					<view class="selecttitle marginAuto">切换收款账户</view>
				</view>
				<view class="typeeach marginAuto" style="margin-top: 60rpx;" @click="paytype=1">
					<view class="types flex">
						<view class="goalmsgl flex">
							<uv-icon name='weixin-circle-fill' size="30" color="#0ABC64"></uv-icon>
							<view class="goalmsgltxt">微信</view>
						</view>
						<view class="goalmsgr">
							<uv-icon name="checkbox-mark" size="30" :color="paytype == 1 ? '#0E71EB':'#fff'"></uv-icon>
						</view>
					</view>
				</view>
				<view class="typeeach marginAuto" @click="paytype=2" style="padding:20rpx 0 40rpx;">
					<view class="types flex">
						<view class="goalmsgl flex">
							<uv-icon name='zhifubao-circle-fill' size="30" color="#1296DB"></uv-icon>
							<view class="goalmsgltxt">支付宝</view>
						</view>
						<view class="goalmsgr">
							<uv-icon name="checkbox-mark" size="30" :color="paytype == 2 ? '#0E71EB':'#fff'"></uv-icon>
						</view>
					</view>
					<view class="alpayinput marginAuto">
						<input type="text" v-model="username" placeholder="请输入您的真是姓名">
					</view>
				</view>
				<view class="marginAuto" style="width:600rpx;margin-top:80rpx;">
					<uv-button text="确认" @click="enterpaytype()" :customStyle="{
						'background':'#0E71EB',
						'color':'#ffffff',
						'font-size':'30rpx',
						'width':'600rpx',
						'height':'100rpx',
						'border-radius':'20rpx'
					}"></uv-button>
				</view>
			</view>
		</uv-popup>
	</view>
</template>

<script>
	import wxSDK from '../../public/wxSDK';
	export default {
		data() {
			return {
				apifun:this.apifun,
				allmoney:0,
				withnum:'',
				paytype:1,
				acpaytype:1, // 1微信  2支付宝
				username:''
			};
		},
		onLoad() {
			this.usermsg = uni.getStorageSync('usermsg');
			this.allmoney = uni.getStorageSync('usermsg').money
		},
		methods: {
			enter(){
				if(!wxSDK.isWechat()){
					return false
				}
				let sendData = {
					amount:this.withnum,
					name:this.username
				}
				this.apifun.unirequest('/coach/user/withdraw','post',sendData,(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.apifun.toast('提现申请成功');
						setTimeout(()=>{
							uni.reLaunch({
								url:'/pages/tabbar/my'
							})
						},1500)
					}else if(res.code == 10002){  // 未授权
						this.apifun.navigate('/pages/start/fenglogo','sqtype=1')
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			enterpaytype(){  // 确定到账方式
				this.acpaytype = this.paytype;
				this.$refs.sepaytypepop.close();
			}
		},
	};
</script>

<style scoped lang="scss">
	.goalacc{
		width: 690rpx;
		padding: 20rpx 0;
		.goalacctitle{
			font-size: 30rpx;
			color: #222222;
			line-height:80rpx;
		}
		.goalmsg{
			padding: 20rpx 0;
			justify-content: space-between;
			.goalmsgl{
				line-height: 60rpx;
				.goalmsgltxt{
					font-size: 36rpx;
					color: #333333;
					margin-left: 20rpx;
				}
			}
			.goalmsgr{
				margin-top: 16rpx;
			}
		}
	}
	// 提现金额
	.withmoney{
		width: 610rpx;
		padding: 30rpx 40rpx;
		background:#fff;
		border-radius: 20rpx;
		.paymenttitle{
			width: 90%;
			padding: 20rpx 5%;
			line-height: 44rpx;
			color: #333;
			font-size:32rpx;
			border-bottom: 1px solid #F7F7F7;
			display:flex;
			justify-content: space-between;
		}
		.rechmoney{
			width: 80%;
			height:90rpx;
			line-height:90rpx;
			padding: 10rpx 5%;
			display: flex;
			margin-top:24rpx;
			.rechmoney-b{
				color: #333333;
				font-size:48rpx;
			}
			.rechmoney-input{
				width: 65%;
				height:90rpx;
				line-height:90rpx;
				margin-left: 20rpx;
				input{
					width: 100%;
					height:90rpx;
					line-height:90rpx;
					text-align: center;
					font-size:40rpx;
					color: #333;
				}
			}
			.rechmoney-btn{
				color:#D72C29;
				font-size: 32rpx;
				width: 150rpx;
				text-align: center;
			}
		}
		.allmoeny{
			padding-top:20rpx;
			line-height:50rpx;
			font-size: 24rpx;
			color: #999999;
		}
	}
	// 选择收款账户
	.paytypeblock{
		height:700rpx;
		overflow-y: scroll;
		background: #fff;
		position: relative;
		border-top-right-radius:30rpx;
		border-top-left-radius:30rpx;
		.buypopuptop{
			position: sticky;
			top: 0;
			left: 0;
			z-index: 10;
			.selectclose{
				position: absolute;
				left:40rpx;
				top:40rpx;
			}
			.selecttitle {
				width: 100%;
				height: 110rpx;
				line-height: 110rpx;
				background-color: #fff;
				text-align: center;
				color: #333333;
				font-size: 36rpx;
				border-top-right-radius:30rpx;
				border-top-left-radius:30rpx;
			}
			.selectall{
				width: 90%;
				padding-bottom:50rpx;
			}
		}
		.typeeach{
			width: 690rpx;
			border-bottom: 1px solid #EDEDED;
			.types{
				padding: 24rpx 0;
				justify-content: space-between;
				.goalmsgl{
					line-height: 60rpx;
					.goalmsgltxt{
						font-size: 36rpx;
						color: #333333;
						margin-left: 20rpx;
					}
				}
				.goalmsgr{}
			}
			.alpayinput{
				width: 560rpx;
				height: 80rpx;
				line-height: 80rpx;
				background:#F7F7F7;
				border-radius:10rpx;
				input{
					width:90%;
					padding:0 5%;
					height: 80rpx;
					line-height: 80rpx;
				}
			}
		}
	}
	.alpayinput{
		width: 560rpx;
		height: 80rpx;
		line-height: 80rpx;
		background:#f7f7f7;
		border-radius:10rpx;
		margin:30rpx auto;
		input{
			width:90%;
			padding:0 5%;
			height: 80rpx;
			line-height: 80rpx;
		}
	}
</style>